package com.zsh.wanandroid.common;

import android.content.Context;

/**
 * @author zsh
 * @date 2019/10/21.
 * 功能：Application代理类
 */

public class ApplicationProxy {

    private static APP mApp;

    public static ApplicationProxy getInstance() {
        return SingletonHolder.instance;
    }

    private static class SingletonHolder {
        private static final ApplicationProxy instance = new ApplicationProxy();
    }

    public void setApplication(APP app) {
        if (null == app) {
            throw new IllegalArgumentException("The app can not be null!");
        }

        mApp = app;
    }

    public APP getApplication() {
        if (null == mApp) {
            throw new IllegalArgumentException("The app is null, need call setApplication in Host*Application attachBase_Fun");
        }
        return mApp;
    }

    public Context getApplicationContext() {
        if (null == mApp) {
            throw new IllegalArgumentException("The app is null, need call setApplication in Host*Application attachBase_Fun");
        }
        return mApp.getApplicationContext();
    }

}
